package com.doubletick.proxy.ipidea.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.doubletick.common.annotation.Log;
import com.doubletick.common.core.controller.BaseController;
import com.doubletick.common.core.domain.AjaxResult;
import com.doubletick.common.enums.BusinessType;
import com.doubletick.proxy.ipidea.domain.ProxyFlowChargeHistory;
import com.doubletick.proxy.ipidea.service.IProxyFlowChargeHistoryService;
import com.doubletick.common.utils.poi.ExcelUtil;
import com.doubletick.common.core.page.TableDataInfo;

/**
 * 流量充值历史Controller
 * 
 * @author ruoyi
 * @date 2024-07-16
 */
@RestController
@RequestMapping("/proxy/flowChargeHistory")
public class ProxyFlowChargeHistoryController extends BaseController
{
    @Autowired
    private IProxyFlowChargeHistoryService proxyFlowChargeHistoryService;

    /**
     * 查询流量充值历史列表
     */
    @PreAuthorize("@ss.hasPermi('proxy:flowChargeHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProxyFlowChargeHistory proxyFlowChargeHistory)
    {
        startPage();
        List<ProxyFlowChargeHistory> list = proxyFlowChargeHistoryService.selectProxyFlowChargeHistoryList(proxyFlowChargeHistory);
        return getDataTable(list);
    }

    /**
     * 导出流量充值历史列表
     */
    @PreAuthorize("@ss.hasPermi('proxy:flowChargeHistory:export')")
    @Log(title = "流量充值历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProxyFlowChargeHistory proxyFlowChargeHistory)
    {
        List<ProxyFlowChargeHistory> list = proxyFlowChargeHistoryService.selectProxyFlowChargeHistoryList(proxyFlowChargeHistory);
        ExcelUtil<ProxyFlowChargeHistory> util = new ExcelUtil<ProxyFlowChargeHistory>(ProxyFlowChargeHistory.class);
        util.exportExcel(response, list, "流量充值历史数据");
    }

    /**
     * 获取流量充值历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('proxy:flowChargeHistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(proxyFlowChargeHistoryService.selectProxyFlowChargeHistoryById(id));
    }

    /**
     * 新增流量充值历史
     */
    @PreAuthorize("@ss.hasPermi('proxy:flowChargeHistory:add')")
    @Log(title = "流量充值历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProxyFlowChargeHistory proxyFlowChargeHistory)
    {
        return toAjax(proxyFlowChargeHistoryService.insertProxyFlowChargeHistory(proxyFlowChargeHistory));
    }

    /**
     * 修改流量充值历史
     */
    @PreAuthorize("@ss.hasPermi('proxy:flowChargeHistory:edit')")
    @Log(title = "流量充值历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProxyFlowChargeHistory proxyFlowChargeHistory)
    {
        return toAjax(proxyFlowChargeHistoryService.updateProxyFlowChargeHistory(proxyFlowChargeHistory));
    }

    /**
     * 删除流量充值历史
     */
    @PreAuthorize("@ss.hasPermi('proxy:flowChargeHistory:remove')")
    @Log(title = "流量充值历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(proxyFlowChargeHistoryService.deleteProxyFlowChargeHistoryByIds(ids));
    }
}
